//
//  CarAroundDataSource.m
//  JxCarios
//
//  Created by xcq on 15/1/29.
//  Copyright (c) 2015年 xiongchuanqi. All rights reserved.
//

#import "CarAroundDataSource.h"
#import "Common.h"

@implementation CarAroundDataSource

- (void)carAroundInfo:(void (^)(id))callback anfFail:(void (^)(id))failCallBack{
    NSMutableDictionary *dic = [NSMutableDictionary new];
    [dic setObject:_lon forKey:@"lon"];
    [dic setObject:_lat forKey:@"lat"];
    [dic setObject:_page forKey:@"page"];
    [dic setObject:_dic_type forKey:@"dic_type"];
    
    [self msg:@"imisellerlist" parameters:dic requestIdentifier:2001 success:^(id result) {
        callback(result);
    } fail:^(id result) {
        failCallBack(result);
    }];
    
}

//imisellerlistbycity
- (void)carAroundInfoWithCityId:(void (^)(id))callback anfFail:(void (^)(id))failCallBack{
    NSMutableDictionary *param = [NSMutableDictionary new];
    [param setObject:_cityId forKey:@"city"];
    [param setObject:_dic_type forKey:@"dic_type"];
    [param setObject:_page forKey:@"page"];
    
    [self msg:@"imisellerlistbycity" parameters:param requestIdentifier:1992 success:^(id result) {
        callback(result);
    } fail:^(id result) {
        failCallBack(result);
    }];
}

- (void)carAroundShopDetail:(void (^)(id))callback anfFail:(void (^)(id))failCallBack{
    NSMutableDictionary *dic = [NSMutableDictionary new];
    [dic setObject:_shopId forKey:@"sellerid"];
    [dic setObject:_dic_type forKey:@"dic_type"];
    
    [self msg:@"imiseller" parameters:dic requestIdentifier:2004 success:^(id result) {
        callback(result);
    }fail:^(id result) {
        failCallBack(result);
    }];
}

- (void)carRefrsh:(void (^)(id))callback anfFail:(void (^)(id))failCallBack{
    NSMutableDictionary *dic = [NSMutableDictionary new];
    [dic setObject:_shopId forKey:@"sellerid"];
    [dic setObject:_dic_type forKey:@"dic_type"];
    [dic setObject:_page forKey:@"page"];
    
    [self msg:@"imisellerpage" parameters:dic requestIdentifier:2005 success:^(id result) {
        callback(result);
    } fail:^(id result) {
        failCallBack(result);
    }];
}

- (void)getShopTravelAndPullcar:(SIMPLE_BLOCK_MAKE(id result))callback anfFail:(void (^)(id))failCallBack{
    NSMutableDictionary *dic = [NSMutableDictionary new];
    [dic setObject:_dic_type forKey:@"dic_type"];
    [dic setObject:_shopId forKey:@"sellerid"];
    
    [self msg:@"imisellertwo" parameters:dic requestIdentifier:2002 success:^(id result) {
        callback(result);
    }fail:^(id result) {
        failCallBack(result);
    }];
    
}

- (void)getRoadsideAssistance:(void (^)(id ))callback anfFail:(void (^)(id))failCallBack{
    NSMutableDictionary *dic = [NSMutableDictionary new];
    [dic setObject:_shopId forKey:@"sellerid"];
    [self msg:@"imisave" parameters:dic requestIdentifier:2003 success:^(id result) {
        callback(result);
    } fail:^(id result) {
        failCallBack(result);
    }];
}
//获取兴趣点--车周边
- (void)getServicePoint:(void (^)(id))callback anfFail:(void (^)(id))failCallBack{
    
    [self msg:@"imiservice" parameters:@{} requestIdentifier:2007 success:^(id result) {
        callback(result);
    }fail:^(id result) {
        failCallBack(result);
    }];
    
}

- (void)queryOilCardDetail:(void (^)(id))callback anfFail:(void (^)(id))failCallBack {
    NSMutableDictionary *dic = [NSMutableDictionary new];
    [dic setObject:[Common currentUserId] forKey:@"member_id"];
    
    [self msg:@"imicardlist" parameters:dic requestIdentifier:2008 success:^(id result) {
        callback(result);
    }fail:^(id result) {
        failCallBack(result);
    }];
}


//imicardbind
- (void)bindOilCard:(void (^)(id))callback anfFail:(void (^)(id))failCallBack {
    NSMutableDictionary *dic = [NSMutableDictionary new];
    [dic setObject:[Common currentUserId] forKey:@"member_id"];
    [dic setObject:_oilCard forKey:@"card_number"];
    [dic setObject:_name forKey:@"holder_name"];
    [self msg:@"imicardbind" parameters:dic requestIdentifier:2009 success:^(id result) {
        callback(result);
    }fail:^(id result) {
        failCallBack(result);
    }];
    
}
//imicarddelete
- (void)deleteOilCard:(void (^)(id))callback anfFail:(void (^)(id))failCallBack{
    NSMutableDictionary *dic = [NSMutableDictionary new];
    [dic setObject:_oilCard forKey:@"card_number"];
    [dic setObject:[Common currentUserId] forKey:@"member_id"];
    [self msg:@"imicarddelete" parameters:dic requestIdentifier:2010 success:^(id result) {
        callback(result);
    }fail:^(id result) {
        failCallBack(result);
    }];
}

- (void)oilCardDetail:(void (^)(id))callback anfFail:(void (^)(id))failCallBack{
    NSMutableDictionary *dic = [NSMutableDictionary new];
    [dic setObject:_oilCard forKey:@"card_number"];
    
    
    [self msg:@"imicarddetail" parameters:dic requestIdentifier:2011 success:^(id result) {
        callback(result);
    }fail:^(id result) {
        failCallBack(result);
    }];
    
}

//imivbtocard
- (void)scoreExchangeOilCar:(void (^)(id))callback anfFail:(void (^)(id))failCallBack{
    NSMutableDictionary *param = [NSMutableDictionary new];
    [param setObject:_oilCard forKey:@"card_number"];
    [param setObject:_name forKey:@"holder_name"];
    [param setObject:[Common currentUserId] forKey:@"memberid"];
    [param setObject:_vb forKey:@"vb"];
    [self msg:@"imivbtocard" parameters:param requestIdentifier:2014 success:^(id result) {
        callback(result);
    } fail:^(id result) {
        failCallBack(result);
    }];
    
}
//imipayrefund
- (void)getCurrenScore:(void (^)(id))callback anfFail:(void (^)(id))failCallBack{
    NSMutableDictionary *param = [NSMutableDictionary new];
    [param setObject:[Common currentUserId] forKey:@"memberid"];
    [self msg:@"imigetvb" parameters:param requestIdentifier:2012 success:^(id result) {
        callback(result);
    } fail:^(id result) {
        failCallBack(result);
    }];
}

/*
 *member_id     10      用户id
 pay_way        0(或者1)	支付方式，0代表线下支付（当面付），1代表线上支付
 order          [{good_id:'',price:'',pay_money:'',use_point:''},..]	Jsonarray格式，代表商品详情，good_id是商品id，price是商品价格，pay_money是实付金额，use_point是实付v币数
 */
//imicreateorder
- (void)getShopId:(SIMPLE_BLOCK_MAKE(id result))callback
          anfFail:(SIMPLE_BLOCK_MAKE(id result))failCallBack {
    NSMutableDictionary *param = [NSMutableDictionary new];
    [param setObject:[Common currentUserId] forKey:@"member_id"];
    [param setObject:_pay_away  forKey:@"pay_way"];
    [param setObject:_orderArr  forKey:@"order"];
    [self msg:@"imicreateorder" parameters:param requestIdentifier:2013 success:^(id result) {
        callback(result);
    } fail:^(id result) {
        failCallBack(result);
    }];
}
//imijoinorder
- (void)mergeShopId:(SIMPLE_BLOCK_MAKE(id result))callback
            anfFail:(SIMPLE_BLOCK_MAKE(id result))failCallBack{
    NSMutableDictionary *param = [NSMutableDictionary new];
    [param setObject:_priceSum forKey:@"price"];
    [param setObject:_orderArr forKey:@"order_id"];
    
    [self msg:@"imijoinorder" parameters:param requestIdentifier:2014 success:^(id result) {
        callback(result);
    } fail:^(id result) {
        failCallBack(result);
    }];
}

//imishare
- (void)getShareRule:(void (^)(id))callback anfFail:(void (^)(id))failCallBack{
    
    [self msg:@"imishare" parameters:@{} requestIdentifier:2015 success:^(id result) {
        callback(result);
    }fail:^(id result) {
        failCallBack(result);
    }];
}

/*
 *sharetype	 weibo_share	分享类型， 即‘分享规则’接口返回值里面的:SHARE_TYPE值
 memberid	 10	  用户id
 vb	5	可获积分，即‘分享规则’接口返回值里面的:SHARE_VB值
 */
//imisharegetvb

//如果登陆就传入登陆的id 如果没有登录就传空
- (void)getshareScope:(void (^)(id))callback anfFail:(void (^)(id))failCallBack{
    NSMutableDictionary *param = [NSMutableDictionary new];
    [param setObject:_shareType forKey:@"sharetype"];
    [param setObject:_shopId forKey:@"memberid"];
    [param setObject:_vb forKey:@"vb"];
    
    
    [self msg:@"imisharegetvb" parameters:param requestIdentifier:2016 success:^(id result) {
        callback(result);
    }fail:^(id result) {
        failCallBack(result);
    }];
}
/*
 *type	imipoint	需要请求的接口名称
 pointype	0	请求数据类型：油卡（0）、服务（1）
 page	1	默认请求第一页
 */
- (void)getScopeExchange:(void (^)(id))callback anfFail:(void (^)(id))failCallBack {
    NSMutableDictionary *param = [NSMutableDictionary new];
    [param setObject:_converType forKey:@"pointype"];
    [param setObject:_page forKey:@"page"];
    
    [self msg:@"imipoint" parameters:param requestIdentifier:2017 success:^(id result) {
        NSLog(@"%@",result);
        callback(result);
    }fail:^(id result) {
        failCallBack(result);
    }];
    
}

- (void)scopeEchangeDetail:(void (^)(id))callback anfFail:(void (^)(id))failCallBack {
    NSMutableDictionary *param = [NSMutableDictionary new];
    [param setObject:[Common currentUserId] forKey:@"memberid"];
    [param setObject:_shopId forKey:@"goodid"];
    
    if ([_converType isEqualToString:@"0"]) { //油卡
        [self msg:@"imivbforcard" parameters:param requestIdentifier:2018 success:^(id result) {
            callback(result);
        }fail:^(id result) {
            failCallBack(result);
        }];
    }else{ //服务
        [self msg:@"imivbforservice" parameters:param requestIdentifier:2019 success:^(id result) {
            callback(result);
        }fail:^(id result) {
            failCallBack(result);
        }];
    }
}

/*
 *type	imivbtoservice	需要请求的接口名称
 memberid	10	用户id
 sellerid	10	商家id
 goodid	10	商品id
 goodname	江西车联	商品名称
 vb	30	所需vb
 */
- (void)scopeEchangeService:(void (^)(id))callback anfFail:(void (^)(id))failCallBack {
    NSMutableDictionary *param = [NSMutableDictionary new];
    [param setObject:[Common currentUserId] forKey:@"memberid"];
    [param setObject:_shopId forKey:@"sellerid"];
    [param setObject:_goodId forKey:@"goodid"];
    [param setObject:_name forKey:@"goodname"];
    [param setObject:_vb forKey:@"vb"];
    
    [self msg:@"imivbtoservice" parameters:param requestIdentifier:2020 success:^(id result) {
        callback(result);
    }fail:^(id result) {
        failCallBack(result);
    }];
    
}

/*
 *type	imivbtocard	需要请求的接口名称
 memberid	10	用户id
 card_number	1007894564655222	油卡号
 holder_name	江西车联	持卡人
 vb	30	所需积分
 请求示例
 */
- (void)scopeEchangeOilCard:(void (^)(id))callback anfFail:(void (^)(id))failCallBack {
    NSMutableDictionary *param = [NSMutableDictionary new];
    [param setObject:[Common currentUserId] forKey:@"memberid"];
    [param setObject:_oilCard forKey:@"card_number"];
    [param setObject:_name forKey:@"holder_name"];
    [param setObject:_vb forKey:@"vb"];
    
    
    [self msg:@"imivbtocard" parameters:param requestIdentifier:2021 success:^(id result) {
        callback(result);
    }fail:^(id result) {
        failCallBack(result);
    }];
}

//imipayvb
- (void)getScopeConvertRule:(void (^)(id))callback anfFail:(void (^)(id))failCallBack{
    NSMutableDictionary *param = [NSMutableDictionary new];
    [param setObject:[Common currentUserId] forKey:@"memberid"];
    [self msg:@"imipayvb" parameters:param requestIdentifier:2022 success:^(id result) {
        callback(result);
    }fail:^(id result) {
        failCallBack(result);
    }];
}

//imipay
- (void)getScopePayRule:(void (^)(id))callback anfFail:(void (^)(id))failCallBack{
    NSMutableDictionary *param = [NSMutableDictionary new];
    [param setObject:[Common currentUserId] forKey:@"memberid"];
    [self msg:@"imipay" parameters:param requestIdentifier:2023 success:^(id result) {
        callback(result);
    }fail:^(id result) {
        failCallBack(result);
    }];
}

//imipayrefund
- (void)userVbPay:(void (^)(id))callback anfFail:(void (^)(id))failCallBack{
    NSMutableDictionary *param = [NSMutableDictionary new];
    [param setObject:[Common currentUserId] forKey:@"member_id"];
    [param setObject:self.priceSum forKey:@"topup_money"];
    
    [self msg:@"imipayforvb" parameters:param requestIdentifier:2024 success:^(id result) {
        callback(result);
    }fail:^(id result) {
        failCallBack(result);
    }];
}

/*
 *type	imimsg	需要请求的接口名称
 memberid	10	用户id
 page	1	第几页（页数）
 */
- (void)getMyMessage:(void (^)(id))callback anfFail:(void (^)(id))failCallBack{
    NSMutableDictionary *param = [NSMutableDictionary new];
    [param setObject:[Common currentUserId] forKey:@"memberid"];
    [param setObject:_page forKey:@"page"];
    
    [self msg:@"imimsg" parameters:param requestIdentifier:2025 success:^(id result) {
        callback(result);
    }fail:^(id result) {
        failCallBack(result);
    }];
}

//imicitylist
- (void)getCityArr:(void (^)(id))callback anfFail:(void (^)(id))failCallBack{
    
    [self msg:@"imicitylist" parameters:@{@"page":_page} requestIdentifier:2027 success:^(id result) {
        callback(result);
    } fail:^(id result) {
        failCallBack(result);
    }];
}


- (void)getHotCity:(void (^)(id))callback anfFail:(void (^)(id))failCallBack{
    [self msg:@"imihotcitylist" parameters:@{@"page":@"1"} requestIdentifier:2026 success:^(id result) {
        callback(result);
    } fail:^(id result) {
        failCallBack(result);
    }];
}



- (void)getMyOrder:(void (^)(id))callback anfFail:(void (^)(id))failCallBack {
    NSMutableDictionary *param = [NSMutableDictionary new];
    [param setObject:[Common currentUserId] forKey:@"memberid"];
    [self msg:@"imimyorder" parameters:param requestIdentifier:2027 success:^(id result) {
        callback(result);
    } fail:^(id result) {
        failCallBack(result);
    }];
}

/*
 type	imimyorderlist	需要请求的接口名称
 memberid	10	用户id
 ordertype	1	订单类型（1代表已支付，4代表积分兑换，5代表线上，6代表线下也就是当面付）
 page	1	第几页
 */
- (void)getOrderDetail:(void (^)(id))callback anfFail:(void (^)(id))failCallBack{
    NSMutableDictionary *param = [NSMutableDictionary new];
    [param setObject:[Common currentUserId] forKey:@"memberid"];
    [param setObject:_dic_type forKey:@"ordertype"];
    [param setObject:_page forKey:@"page"];
    
    [self msg:@"imimyorderlist" parameters:param requestIdentifier:2028 success:^(id result) {
        callback(result);
    }fail:^(id result) {
        failCallBack(result);
    }];
    
}
/*
 *
 type	imipayrefund	需要请求的接口名称
 member_id	10	用户id
 order_id	28	订单号
 refund_desc	abc..	退款理由
 zfb	111	支付宝号码,支付宝和银行信息只需要一种，没有的可以传空值
 bank_open	..	开户行
 bank_card	..	银行卡号
 bank_name	..	开户人姓名
 */
- (void)getTuiKuan:(void (^)(id))callback anfFail:(void (^)(id))failCallBack {
    NSMutableDictionary *param = [NSMutableDictionary new];
    [param setObject:[Common currentUserId] forKey:@"member_id"];
    [param setObject:_orderId forKey:@"order_id"];
    [param setObject:_refund_desc forKey:@"refund_desc"];
    [param setObject:_zfb forKey:@"zfb"];
    [param setObject:_bank_open forKey:@"bank_open"];
    [param setObject:_bank_card forKey:@"bank_card"];
    [param setObject:_bank_name forKey:@"bank_name"];

    [self msg:@"imipayrefund" parameters:param requestIdentifier:2029 success:^(id result) {
        callback(result);
    } fail:^(id result) {
        failCallBack(result);
    }];
    
}
//type	imibackorderlist	需要请求的接口名称
//memberid	10	用户id
//page	1	第几页
- (void)refund:(void (^)(id))callback anfFail:(void (^)(id))failCallBack {
    NSMutableDictionary *param = [NSMutableDictionary new];
    [param setObject:[Common currentUserId] forKey:@"memberid"];
    [param setObject:_page forKey:@"page"];
    [self msg:@"imibackorderlist" parameters:param requestIdentifier:2030 success:^(id result) {
        callback(result);
    }fail:^(id result) {
        failCallBack(result);
    }];
}

//type	imicardorderlist	需要请求的接口名称
//memberid	10	用户id
//page	1	第几页
- (void)getOilCardOrder:(void (^)(id))callback anfFail:(void (^)(id))failCallBack {
    NSMutableDictionary *param = [NSMutableDictionary new];
    [param setObject:[Common currentUserId] forKey:@"memberid"];
    [param setObject:_page forKey:@"page"];
    [self msg:@"imicardorderlist" parameters:param requestIdentifier:2031 success:^(id result) {
        callback(result);
    }fail:^(id result) {
        failCallBack(result);
    }];
}


- (void)getOilNumDetail:(void (^)(id))callback anfFail:(void (^)(id))failCallBack {
    NSMutableDictionary *param = [NSMutableDictionary new];
    [param setObject:_oilCard forKey:@"id"];
    
    //imicardorderdetail
    [self msg:@"imicardorderdetail" parameters:param requestIdentifier:2032 success:^(id result) {
        callback(result);
    }fail:^(id result) {
        failCallBack(result);
    }];
}

/*
 *type	imibackorderdetail	需要请求的接口名称
 id	10	退款订单id
 */

- (void)getTuiKuanDetail:(void (^)(id))callback anfFail:(void (^)(id))failCallBack {
    NSMutableDictionary *param = [NSMutableDictionary new];
    [param setObject:_oilCard forKey:@"id"];
    
    //imicardorderdetail
    [self msg:@"imibackorderdetail" parameters:param requestIdentifier:2033 success:^(id result) {
        callback(result);
    }fail:^(id result) {
        failCallBack(result);
    }];
}

- (void)getGuaGuaLe:(void (^)(id))callback anfFail:(void (^)(id))failCallBack {
    //memberid
    NSMutableDictionary *param = [NSMutableDictionary new];
    if ([Common currentUserId] && [Common currenLoginStatus]) {
        [param setObject:[Common currentUserId] forKey:@"memberid"];
    }else {
        [param setObject:@"" forKey:@"memberid"];
    }
    [self msg:@"imiguaguale" parameters:param requestIdentifier:2035 success:^(id result) {
        callback(result);
    }fail:^(id result) {
        failCallBack(result);
    }];
}

- (void)getOrderTableDetail:(void (^)(id))callback anfFail:(void (^)(id))failCallBack {
    NSMutableDictionary *param = [NSMutableDictionary new];
    [param setObject:_shopId forKey:@"id"];
    
    //imiorderdetail
    [self msg:@"imiorderdetail" parameters:param requestIdentifier:2035 success:^(id result) {
        callback(result);
    }fail:^(id result) {
        failCallBack(result);
    }];
}

- (void)getVbHistory:(void (^)(id))callback anfFail:(void (^)(id))failCallBack {
    //imimembervblist
    NSMutableDictionary *param = [NSMutableDictionary new];
    [param setObject:@"10" forKey:@"pagesize"];
    [param setObject:_page forKey:@"page"];
    [param setObject:[Common currentUserId] forKey:@"member_id"];
    [param setObject:@"" forKey:@"create_date"];
    
    [self msg:@"imimembervblist" parameters:param requestIdentifier:2044 success:^(id result) {
        callback(result);
    }fail:^(id result) {
        failCallBack(result);
    }];
    
}


- (void)getBankArr:(void (^)(id))callback anfFail:(void (^)(id))failCallBack {
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    [dic setObject:@"0" forKey:@"seller_id"];
    [self msg:@"isibindbank" parameters:dic requestIdentifier:2045 success:^(id result) {
        callback(result);
    }fail:^(id result) {
        failCallBack(result);
    }];
}

@end
